<?php

namespace App\Livewire\Components;

use Livewire\Component;
use App\Models\Category as CategoryModel;

class Category extends Component
{

    public $categorys;

    public function mount()
    {
        $categoryModel = CategoryModel::query()
            ->select(['id', 'name'])
            ->withCount('article')
            ->get();
        $this->categorys = $categoryModel;
    }

    public function render()
    {
        return view('livewire.components.category', [
            'categorys' => $this->categorys,
        ]);
    }
}
